-- stair mods active
local stairs_mod = minetest.get_modpath("stairs")
local stairs_redo = stairs_mod and stairs.mod and stairs.mod == "redo"
local stairs_plus = minetest.global_exists("stairsplus")

-- stair selection function
local do_stair = function(
		description, name, node, groups, texture, sound, sunlight, light_source)

	if stairs_redo then

		stairs.register_all(name, node,	groups, texture, description, sound)

	elseif stairs_plus then

		local mod = "caverealms"

		stairsplus:register_all(mod, name, node, {
			description = description,
			tiles = texture,
			groups = groups,
			sunlight_propagates = sunlight,
			light_source = light_source,
			sounds = sound
		})

		-- aliases need to be set for previous stairs to avoid unknown nodes
		minetest.register_alias_force("stairs:stair_" .. name,
				mod .. ":stair_" .. name)

		minetest.register_alias_force("stairs:stair_outer_" .. name,
				mod .. ":stair_" .. name .. "_outer")

		minetest.register_alias_force("stairs:stair_inner_" .. name,
				mod .. ":stair_" .. name .. "_inner")

		minetest.register_alias_force("stairs:slab_"  .. name,
				mod .. ":slab_"  .. name)

	elseif stairs_mod then

		stairs.register_stair_and_slab(name, node, groups, texture,
				description .. " Stair", description .. " Slab", sound)
	end
end


-- Register Stairs (stair mod will be auto-selected)
do_stair(
	"Glow Obsidian Brick",
	"glow_obsidian_brick",
	"caverealms:glow_obsidian_brick",
	{cracky = 1, level = 2},
	{"caverealms_glow_obsidian_brick.png"},
	default.node_sound_stone_defaults(),
	false,
	7)

do_stair(
	"Glow Obsidian Brick",
	"glow_obsidian_brick_2",
	"caverealms:glow_obsidian_brick_2",
	{cracky = 1, level = 2},
	{"caverealms_glow_obsidian_brick_2.png"},
	default.node_sound_stone_defaults(),
	false,
	9)

do_stair(
	"Glow Obsidian Glass",
	"glow_obsidian_glass",
	"caverealms:glow_obsidian_glass",
	{cracky = 3},
	{"caverealms_glow_obsidian_glass_quarter.png"},
	default.node_sound_glass_defaults(),
	true,
	13)
